/**
 * @author <a href="mailto:xingxiao@gtmap.cn">xingxiaofeng</a>
 * @version2.1 2021-06-17
 * @description
 */
public abstract class AbstractHandler
{
    public int maxAmount;
    public String name;
    public AbstractHandler(int maxAmount,String name){
        this.maxAmount=maxAmount;
        this.name=name;
    }
    private AbstractHandler nextHandler;
    public void setNextHandler(AbstractHandler abstractHandler){
        nextHandler=abstractHandler;
    }

    public final void handleLoan(int amount){
       if(this.maxAmount>=amount){
              this.agree(amount);
       }else {
           if(this.nextHandler!=null){
               this.nextHandler.handleLoan(amount);
               System.out.println(name+"贷款已超过我的审批权限，已提交我的上级审批！");
           } else {
               System.out.println("流程节点未实例化！");
           }

       }
    }

    protected abstract void agree(int amount);
}
